﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Register.Command;
using Register.DALFactory;
using Register.IDAL;
using Register.Model;
namespace Register.BLL
{
    /// <summary> 
    /// FileName: DoctorUserInfoBLL.cs    
    /// CLRVersion: 4.0.30319.269    
    /// Author: DoubleZ    
    /// Corporation:     
    /// Description:     
    /// DateTime: 2012/6/29 17:23:54    
    /// </summary>
  public   class DoctorUserInfoBLL
    {
        private static String typeNameKey = "IDoctorUserInfoDALKey";
        /// <summary>
        /// 添加医生用户
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static bool AddDoctorUserInfo(Model.DoctorUserInfo model)
        {
            IDoctorUserDALInfo iDoctorUserInfo = DALFactory<IDoctorUserDALInfo>.Create(typeNameKey);
            try
            {
                if (iDoctorUserInfo .AddDoctorUserInfo(model)> 0)
                    return true;
                else
                    return false;
            }
            catch (Exception e)
            {
                LogRecordHelper.LogNote("ERROR", e.Message);
                throw e;
            }
        }
        #region 获取医生用户信息
        public static List<Model.DoctorUserInfo> GetPagedDoctorUserInfo(int size, int pageIndex, string where)
        {
            IDoctorUserDALInfo iDoctorUserInfo = DALFactory<IDoctorUserDALInfo>.Create(typeNameKey);
            try
            {
                return iDoctorUserInfo.GetPagedDoctorUserInfo(size,pageIndex,where);
            }
            catch (Exception e)
            {
                LogRecordHelper.LogNote("ERROR", e.Message);
                throw e;
            }
        }
        public static int GetDoctorDoctorInfoCount(string where)
        {
            IDoctorUserDALInfo iDoctorUserInfo = DALFactory<IDoctorUserDALInfo>.Create(typeNameKey);

            try
            {
                return iDoctorUserInfo.GetDoctorUserInfoCount(where);
            }
            catch (Exception e)
            {
                LogRecordHelper.LogNote("ERROR", e.Message);
                throw e;
            }
        }
        #endregion
        #region 根据医生ID获取医生姓名
        public static string GetDoctorNameById(string doctorID)
        {
            IDoctorUserDALInfo iDoctorInfo = DALFactory<IDoctorUserDALInfo>.Create(typeNameKey);
            try
            {
                return iDoctorInfo.GetDoctorNameById(doctorID);

            }
            catch (Exception e)
            {
                LogRecordHelper.LogNote("ERROR", e.Message);
                throw e;
            }
        }
        #endregion
        #region 删除医生用户
        public static bool DeleteDoctorUserInfo(string doctorUserID)
        {
           IDoctorUserDALInfo iDoctorUserInfo = DALFactory<IDoctorUserDALInfo>.Create(typeNameKey);
            try
            {
                if (iDoctorUserInfo.DeleteDoctorUserInfo(doctorUserID)>0)
                    return true;
                else
                    return false;
            }
            catch (Exception e)
            {
                LogRecordHelper.LogNote("ERROR", e.Message);
                throw e;
            }
        }
        #endregion
        #region 更新医生用户信息
        #region 更新医生
        public static bool UpdateDoctorUserInfo(Model.DoctorUserInfo model)
        {
            IDoctorUserDALInfo iDoctorUserInfo = DALFactory<IDoctorUserDALInfo>.Create(typeNameKey);
            try
            {
                if (iDoctorUserInfo.UpdateDoctorUserInfo(model)> 0)
                {
                    return true;
                }
                else
                    return false;
            }
            catch (Exception e)
            {
                LogRecordHelper.LogNote("ERROR", e.Message);
                throw e;
            }
        }

        #endregion
        #endregion
        #region 检查医生用户名是否已经存在
        public static bool Exists(string  doctorUserName)
        {
            IDoctorUserDALInfo iDoctorUserInfo = DALFactory<IDoctorUserDALInfo>.Create(typeNameKey);

            try
            {
                return iDoctorUserInfo.Exists(doctorUserName);
            }
            catch (Exception e)
            {
                LogRecordHelper.LogNote("ERROR", e.Message);
                throw e;
            }
        }

        #endregion
    }
}
